<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>提供和注入</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="app">
        <my-parent></my-parent>
    </div>
    <template id="son">
        <div>
            子组件
            <h6>我是子组件 {{a}}</h6>
        </div>
    </template>
    
    <template id="father"> 
        <div>
            父组件
            <my-son></my-son>    
        </div>
    </template>
    
    <script>
    const son = {
        template: '#son',
        inject: ['a']
    }

    const father = {
        template: '#father',
        provide: {
            a: 8000
        },
        components: {
            'mySon': son
        }
    }

    // 提供必须在注入的层级之上
    new Vue({
        el: '#app',
        // provide: {
        //     a: 8000
        // }, 
        components: {
            'myParent': father 
        }
    })
    </script>
</body>
</html>